import { GlobalClass } from "../../../com/mui/core/GlobalClass";
import { CursorManager } from "./CursorManager";
import { Game } from "../Game";
import { Global } from "../../../com/gengine/global/Global";
//class CursorManagerImpl
    
    export  class CursorManagerImpl /* flash.display.Sprite */
    {
        constructor()
        {
            
            this.addEventListener(flash.events.Event.ADDED_TO_STAGE, this.addedToStageHandler);
            return;
        }

        public addedToStageHandler(arg1: Object /* flash.events.Event */): void
        {
            this.mouseChildren = false;
            this.mouseEnabled = false;
            this._cursorSkin = GlobalClass.getInstance("CursorSkin");
            this._cursorSkin.mouseChildren = false;
            this._cursorSkin.mouseEnabled = false;
            this.cursorStyle = CursorManager.NO_CURSOR;
            this.addChild(this._cursorSkin);
            return;
        }

        /* internal  */onMouseMoveHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (this._currentMC && this.contains(this._currentMC)) 
            {
                this._currentMC.x = arg1.stageX;
                this._currentMC.y = arg1.stageY;
            }
            arg1.updateAfterEvent();
            return;
        }

        public dispose(): void
        {
            return;
        }

        public get cursorStyle(): string
        {
            return this._cursorStyle;
        }

        public set cursorStyle(arg1: string)
        {
            this._cursorStyle = arg1;
            if (this._currentMC && contains(this._currentMC)) 
            {
                removeChild(this._currentMC);
            }
            if (this._cursorStyle != CursorManager.NO_CURSOR) 
            {
                if (this._cursorStyle != CursorManager.PointMask) 
                {
                    this._currentMC = this._cursorSkin;
                    this._currentMC.gotoAndStop(arg1);
                }
                else 
                {
                    this._currentMC = Game.scene.pointMask;
                    this._currentMC.gotoAndStop(0);
                }
                if (this.contains(this._currentMC) == false) 
                {
                    this.addChild(this._currentMC);
                }
                flash.ui.Mouse.hide();
                this._currentMC.x = mouseX;
                this._currentMC.y = mouseY;
                Global.stage.addEventListener(flash.events.MouseEvent.MOUSE_MOVE, this.onMouseMoveHandler);
            }
            else 
            {
                if (this._currentMC && this.contains(this._currentMC)) 
                {
                    this.removeChild(this._currentMC);
                }
                this.clearFilters();
                flash.ui.Mouse.show();
                Global.stage.removeEventListener(flash.events.MouseEvent.MOUSE_MOVE, this.onMouseMoveHandler);
            }
            return;
        }

        public addFilters(arg1: Array<any>): void
        {
            if (this._cursorStyle != CursorManager.NO_CURSOR) 
            {
                if (this._currentMC) 
                {
                    this._currentMC.filters = arg1;
                }
            }
            return;
        }

        public clearFilters(): void
        {
            if (this._currentMC) 
            {
                this._currentMC.filters = null;
            }
            return;
        }

        /* internal */ /* var */_cursorSkin: Object /* flash.display.MovieClip */;

        /* internal */ /* var */_cursorStyle: string;

        /* internal */ /* var */_currentMC: Object /* flash.display.MovieClip */;
    }
